{% extends "base.html" %}

{% block app_content %}
<div class="row">
    <div class="col-md-6">
        <h1>Hello. {{current_user.username}}</h1>
        <br>
        {%if current_user==user%}
        <a href="{{url_for('edit_profile')}}">Edit Profile</a>
        {%else%}
           {%if current_user.is_following(user)%}
                <a href="{{url_for('unfollow',username=user.username)}}">UnFollow</a>
           {%else%}
                 <a href="{{url_for('follow',username=user.username)}}">Follow</a>
           {%endif%}
        {%endif%}
        <br>
        <br>
        {%include 'posts_content.html'%}
        <hr>
        <nav aria-label="Page navigation">
            <center>
                <ul class="pagination">
                    {%if posts.has_prev%}
                    <li>
                        <a href="{{url_for('user_page',page=posts.prev_num,username=username)}}" aria-label="Previous">
                            <span aria-hidden="true">&laquo; Prev</span>
                        </a>
                    </li>
                    {%endif%}

                    {% for i in posts.iter_pages(left_current = 2, right_current = 2) %}
                    {%if i%}
                    <li class="{%if i==posts.page%}active{%endif%}"><a
                            href="{{url_for('user_page',page=i,username=username)}}">{{i}}</a></li>
                    {%else%}
                    <li><a href="#">...</a></li>
                    {%endif %}
                    {% endfor %}
                    {%if posts.has_next%}
                    <li>
                        <a href="{{url_for('user_page',page=posts.next_num,username=username)}}" aria-label="Next">
                            <span aria-hidden="true">&raquo; Next</span>
                        </a>
                    </li>
                    {%endif%}
                </ul>
            </center>
        </nav>
    </div>
</div>
{%endblock%}